import { Nodes } from '@knno/dom';
import { TabDef, TabEventMap, Tab as UITab } from '../components/tab/tab';
import { JSXProps } from '@knno/dom/jsx';
import { AttrCheck, On, isArray, isBool, isNumber, jsxBuild } from './utils';

export { UITab };

interface TabProps extends JSXProps<UITab>, On<TabEventMap, UITab> {
	tabs?: TabDef[];
	active?: number;
	autoHideTabs?: boolean;
}

const ATTRS: AttrCheck = {
	tabs: isArray,
	active: isNumber,
	autoHideTabs: isBool,
};

export function Tab(props: TabProps, children: Nodes[]): UITab {
	return jsxBuild(new UITab(), props, children, ATTRS);
}
